package com.ioidea.holland.view

import android.content.Context
import com.blankj.utilcode.util.ScreenUtils
import com.lxj.xpopup.XPopup


/**
 * @author: gdy on 2023/4/8:00.
 * @email: 240767446@qq.com
 * @Desc:
 */
object PopupUtils {
    fun listPopup(context: Context, list: Array<String>, block: (String) -> Unit) {
        XPopup.Builder(context)
            .asBottomList(
                "请选择一项", list
            ) { _, text ->
                block.invoke(text)
            }
            .show()
    }

    fun listPopupWithMaxHeight(
        context: Context,
        title:String,
        list: Array<String>,
        maxHeight: Int? = (ScreenUtils.getScreenHeight() / 2),
        block: (Int, String) -> Unit
    ) {
        XPopup.Builder(context)
            .maxHeight(maxHeight ?: (ScreenUtils.getScreenHeight() / 2))
            .asBottomList(
                title, list
            ) { position, text ->
                block.invoke(position, text)
            }
            .show()
    }


}